import React from 'react'
import { Navigate, useLocation } from 'react-router-dom'
const Hoc_login = (Com) => {
  return function Fn(){
     let Location = useLocation()
        let bailist = ['/login', '/404']
        let token=localStorage.getItem('token')
        let flag=bailist.includes(Location.pathname)
        if(flag){
            <Navigate to={Location.pathname}></Navigate>
        }else{
            if(token){
                return<Com></Com>
            }else{
                return<Navigate to={'/login'}></Navigate>
            }
        }
  }
}

export default Hoc_login
